package org.binglan.youziyuepai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.binglan.youziyuepai.entity.PhotographyTag;
import org.binglan.youziyuepai.mapper.PhotographyTagMapper;
import org.binglan.youziyuepai.service.PhotographyTagService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 * 摄影标签表 服务实现类
 * </p>
 *
 * @author sanjin
 * @since 2019-04-09
 */
@Service
public class PhotographyTagServiceImpl extends ServiceImpl<PhotographyTagMapper, PhotographyTag> implements PhotographyTagService {

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public boolean isExistsIds(Collection<Integer> ids) {
        if (ids.size() > 0) {
            QueryWrapper<PhotographyTag> queryWrapper = new QueryWrapper<>();
            queryWrapper.in("id",ids);
            return this.count(queryWrapper) == ids.size();
        }
        return true;
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<PhotographyTag> queryTagsByUserId(String userId) {

        return baseMapper.queryTagsByUserId(userId);
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<PhotographyTag> queryTagsByPersonalDynamicId(String personalDynamicId) {
        return baseMapper.queryTagsByPersonalDynamicId(personalDynamicId);
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<PhotographyTag> queryAllTags() {
        return list(null);
    }
}
